package tool

import (
	"math/rand"
	"strconv"
	"time"
)

// 生产订单号
func GenerateOrderNo() string {
	//return time.Now().Format("20060102150405") + gconv.String(RandInt(1000000000, 9999999899)+100)
	return strconv.Itoa(RandInt(1000000000, 9999999899) + 100)
}

// 生产订单号--遍历重复
func GenerateForOrderNo() string {
	return time.Now().Format("20060102150405") + strconv.Itoa(RandForInt(1000000000, 9999999899)+100)
}

// ---取随机
func RandInt(min, max int) int {
	rand.Seed(time.Now().Unix())
	NewInt := rand.Intn(max)
	if NewInt < min {
		RandInt(min, max)
	}
	return NewInt
}

// --遍历重复  -取随机
func RandForInt(min, max int) int {
	NewInt := rand.Intn(max)
	if NewInt < min {
		RandInt(min, max)
	}
	return NewInt
}

func StrToInt64(str string) int64 {
	i, err := strconv.ParseInt(str, 10, 64)
	if err != nil {
	}

	return i
}
